package com.happyrecyclingstation.enumeration;

import com.happyrecyclingstation.constant.MessageConstant;
import com.happyrecyclingstation.exception.LoginException;

/**
 * 用户类型枚举
 */
public enum UserType {

    JOB_SEEKER((short) 1, "求职用户"),
    HR((short)2, "招聘用户"),
    ADMIN((short)3, "管理员");

    private final Short userType;
    private final String desc;

    UserType(Short userType, String desc) {
        this.userType = userType;
        this.desc = desc;
    }

    // 根据User的 userType 获取枚举
    public static UserType fromUserType(Short userType) {
        for (UserType type : values()) {
            if (type.userType.equals(userType)) {
                return type;
            }
        }
        throw new LoginException(MessageConstant.INVALID_USER_TYPE);
    }

    // Getters
    public Short getUserType() { return userType; }
    public String getDesc() { return desc; }

}
